############################################################
# Honig Information Power & Location                       #
#														   #
#             Governance                                   #
#           Replication .do File                           #
#         August 15, 2019                                  #
############################################################


****Explanatory Notes

/*

This .do file takes as its input the data following a series of cleaning and preparation steps.

The replication archive does not contain all of these .do files, but they are available upon request.

This replication archive includes:

1) The original data on WB staff as-transmitted by the World Bank in response to Access to Information Request #4614 in 2016;

2) The data following cleaning and preparation;

3) This .do file, which runs analyses based on these data.

The cleaning and preparation .do files are available upon request.  Amongst other things, these files:

-Merge the personnel data with the July 2016 version of the World Bank's public PPR dataset (https://finances.worldbank.org/Other/IEG-World-Bank-Project-Performance-Ratings/rq9d-pctf)

-Generate a presence variable for each type of staff

-Generate a dummy for each individual staff name (these are the "repnumber" binary variables), taking a 1 if the given staff member was present for a given project

Please do not hesitate to write me on dhonig@jhu.edu if I can provide any more clarification or information on these data.

Sincerely,

Dan Honig
August 2019

*/

Use "Honig Information Power Location Replication Data.dta"


*Turning project success into a Likert-type numeric scale

gen Project_Success=1  if IEG_Outcome=="Highly Unsatisfactory"
replace Project_Success=2 if IEG_Outcome=="Unsatisfactory"
replace Project_Success=3 if IEG_Outcome=="Moderately Unsatisfactory"
replace Project_Success=4 if IEG_Outcome=="Moderately Satisfactory"
replace Project_Success=5 if IEG_Outcome=="Satisfactory"
replace Project_Success=6 if IEG_Outcome=="Highly Satisfactory"

**Dropping if project success is missing

drop if Project_Success==.


**Turning Net Commitment (Project Size) Into Millions

replace NetCommitment=NetCommitment/1000000


***Generating interaction terms

rename sfi SFI

gen AnyStaffPrepXSFI=AnyStaff_Prep*SFI
gen CDPrepXSFI=CD_PrepPresenceForEachProject*SFI


gen AnyStaffImpXSFI=AnyStaff_IMP*SFI
gen CDImpXSFI=CD_IMPresenceForEachProject*SFI

***Creating flags for the "active" data that should be used for each analysis

*For preparation, can use all projects approved through 2005
generate Prep_Sample_Dum=1 if ApprovalYr<2006
replace Prep_Sample_Dum=0 if Prep_Sample_Dum==.

*For implementation, can only use projects that completed by 2005

*49 projects have an exitFY of "0".  For those I use the year of project deactivation (which is almost always the same)

generate lastimpyear=ExitFY
replace lastimpyear=DeactivationYr if ExitFY==0
replace lastimpyear=DeactivationYr if DeactivationYr<=ExitFY
generate Implementation_Sample_Dum=1 if lastimpyear<2006
replace Implementation_Sample_Dum=0 if Implementation_Sample_Dum==.

label define dummy 1 yes 0 no

label values Implementation_Sample_Dum dummy
label values Prep_Sample_Dum dummy
label variable Prep_Sample_Dum "Dummy for Inclusion in Preparation Sample"
label variable Implementation_Sample_Dum "Dummy for Inclusion in Implementation Sample"


***Encoding dummy variables for later use
encode Country, gen(Country1)
encode SectorBoard , gen( SectorBoard1 )


**Logging NetCommitment (R2 Comment, Governance RR March 2019)
rename NetCommitment NetCommitmentNoLog
gen NetCommitment=log(NetCommitmentNoLog)
replace NetCommitment=0 if NetCommitmentNoLog<0


**Summary statistics

**Tables 1 & 2: Summary Stats

cd "/Users/danhonig/Dropbox/World Bank Country Managers Country Directors and Performance/Authors Final Version/Replication Archive"

label var Project_Success "Project Success (6 point scale)"
label var AnyStaff_IMP  "Any Staff Implementation Presence"
label var AnyStaff_Prep  "Any Staff Preparation Presence"
label var CD_IMPresenceForEachProject "Country Director Implementation Presence"
label var CD_PrepPresenceForEachProject "Country Director Preparation Presence"
label var SFI "State Fragility Index"
label var NetCommitment "Project Size (Logged Net Commitment Millions)"


label var AnyStaffPrepXSFI "Any Staff Prep*SFI"
label var CDPrepXSFI "Country Director Prep*SFI"


label var AnyStaffImpXSFI "Any Staff Implementation*SFI"
label var CDImpXSFI "Country Director Implementation*SFI"

*Table 1 - Preparation Sample Summary Statistics

sum Project_Success  AnyStaff_Prep CD_PrepPresenceForEachProject  NetCommitment  SFI if Prep_Sample_Dum==1

sutex2 Project_Success  AnyStaff_Prep CD_PrepPresenceForEachProject  NetCommitment  SFI if Prep_Sample_Dum==1, min varlabels saving (SumPreparationTable1FINAL.tex) replace


*Table 2 - Implementation Sample Summary Statistics

sum Project_Success  AnyStaff_IMP CD_IMPresenceForEachProject    NetCommitment  SFI if Implementation_Sample_Dum==1

sutex2 Project_Success  AnyStaff_IMP CD_IMPresenceForEachProject    NetCommitment  SFI if Implementation_Sample_Dum==1, min varlabels saving (SumImplementationTable2FINAL.tex) replace

****Table 3: Direct effect of Staff and CDs on Project Success


eststo clear
eststo: reg Project_Success AnyStaff_IMP NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1  repnumber1-repnumber479 if Implementation_Sample_Dum==1
eststo: reg Project_Success AnyStaff_Prep NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1  if Prep_Sample_Dum==1
eststo: reg Project_Success CD_IMPresenceForEachProject NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1
eststo: reg Project_Success CD_PrepPresenceForEachProject NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1
esttab using Table3FINAL.tex, se label star(* 0.10 ** 0.05 *** 0.01) r2 obslast replace booktabs drop (repnum* *Country1* *IEG_EvalFY* *SectorBoard1*)

***Table 4:  Direct Effects Restricting to Post-Compact Data

eststo clear
eststo: reg Project_Success AnyStaff_IMP NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1  repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996
eststo: reg Project_Success AnyStaff_Prep NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1  if Prep_Sample_Dum==1 & ApprovalYr>1996
eststo: reg Project_Success CD_IMPresenceForEachProject NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996
eststo: reg Project_Success CD_PrepPresenceForEachProject NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996
esttab using Table4FINAL.tex, se label star(* 0.10 ** 0.05 *** 0.01) r2 obslast replace booktabs drop (repnum* *Country1* *IEG_EvalFY* *SectorBoard1*)


***Table 5:  CDs and State Fragility in the Post-Compact Era

eststo clear
eststo: reg Project_Success  CD_IMPresenceForEachProject SFI NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996
eststo: reg Project_Success  CD_IMPresenceForEachProject SFI NetCommitment CDImpXSFI  i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996
eststo: reg Project_Success  CD_PrepPresenceForEachProject SFI  NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996
eststo: reg Project_Success  CD_PrepPresenceForEachProject SFI NetCommitment CDPrepXSFI  i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996
esttab using Table5FINAL.tex, se label star(* 0.10 ** 0.05 *** 0.01) r2 obslast replace booktabs drop (repnum* *Country1* *IEG_EvalFY* *SectorBoard1*)


*Figure 1 - Conditional implementation presence on project success
reg Project_Success CD_IMPresenceForEachProject SFI CDImpXSFI NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996
grinter CD_IMPresenceForEachProject, int(CDImpXSFI) cons(SFI) nom scheme (s1mono) ytitle(Marginal Effect of CD Presence on Project Success Post-Compact)


****Exploring Selection (Response to Governance R&R, April 2018)

*Generating a flag for countries that had a CD present at any time before the strategic compact
gen CD_ever_preCompact=1 if CD_PrepPresenceForEachProject>0 & ExitFY<1997
replace CD_ever_preCompact=1 if CD_IMPresenceForEachProject>0 & ExitFY<1997

tab Country1 if CD_ever_preCompact==1

sort Country1
by Country1: egen countCDprecompact=count(CD_ever_preCompact)

tab Country1 if countCDprecompact>0

replace CD_ever_preCompact=1 if countCDprecompact>0

tab Country1 if CD_ever_preCompact==1
replace CD_ever_preCompact=0 if CD_ever_preCompact==.


*Generating a flag for countries that ever have a CD (pre- or post-compact)
gen CD_ever=1 if CD_PrepPresenceForEachProject>0 
replace CD_ever=1 if CD_IMPresenceForEachProject>0 
by Country1: egen countCD=count(CD_ever)
replace CD_ever=1 if countCD>0

*Identifying countries where a CD only appears post-compact
gen CD_only_post=1 if CD_ever==1 & CD_ever_preCompact==0
replace CD_only_post=0 if CD_only_post==.


***Table 6: CD and State Fragility Post-Compact, excluding countries only with a CD post-compact

eststo clear
eststo: reg Project_Success CD_IMPresenceForEachProject SFI NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996 & CD_only_post==0
eststo: reg Project_Success CD_IMPresenceForEachProject SFI NetCommitment CDImpXSFI  i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996 & CD_only_post==0
eststo: reg Project_Success CD_PrepPresenceForEachProject SFI NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996 & CD_only_post==0
eststo: reg Project_Success CD_PrepPresenceForEachProject SFI NetCommitment CDPrepXSFI  i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996 & CD_only_post==0
esttab using Table6FINAL.tex, se label star(* 0.10 ** 0.05 *** 0.01) r2 obslast replace booktabs drop (repnum* *Country1* *IEG_EvalFY* *SectorBoard1*)


***Robustness Tests (Appendix)


*Appendix Table A1: Table5 as Ordered Logit


eststo clear
eststo: ologit Project_Success CD_IMPresenceForEachProject SFI NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996,  iterate(10)
eststo: ologit Project_Success CD_IMPresenceForEachProject SFI NetCommitment CDImpXSFI  i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996, iterate(10)
eststo: ologit Project_Success CD_PrepPresenceForEachProject SFI NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996, iterate(10)
eststo: ologit Project_Success CD_PrepPresenceForEachProject SFI NetCommitment CDPrepXSFI  i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996, iterate(10)
esttab using AppendixA1_Robustness_Table5OLOGIT_FINAL.tex, se label star(* 0.10 ** 0.05 *** 0.01) r2 obslast replace booktabs drop (repnum* *Country1* *IEG_EvalFY* *SectorBoard1*)


*Appendix Table A2: Table 5 with only PARs (IEG Evals)


eststo clear
eststo: reg Project_Success CD_IMPresenceForEachProject SFI NetCommitment i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996 & IEG_EvalType=="PAR"
eststo: reg Project_Success CD_IMPresenceForEachProject SFI CDImpXSFI NetCommitment  i.Country1 i.IEG_EvalFY i.SectorBoard1 repnumber1-repnumber479 if Implementation_Sample_Dum==1 & ApprovalYr>1996 & IEG_EvalType=="PAR"
eststo: reg Project_Success CD_PrepPresenceForEachProject SFI NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996 & IEG_EvalType=="PAR"
eststo: reg Project_Success CD_PrepPresenceForEachProject SFI CDPrepXSFI NetCommitment i.Country1 i.IEG_EvalFY repnumber1-repnumber479 i.SectorBoard1 if Prep_Sample_Dum==1 & ApprovalYr>1996 & IEG_EvalType=="PAR"
esttab using AppendixA2_Robustness_Table5PARsONLY_FINAL.tex, se label star(* 0.10 ** 0.05 *** 0.01) r2 obslast replace booktabs drop (repnum* *Country1* *IEG_EvalFY* *SectorBoard1*)

****End of File******
